prefix=@prefix@
CFLAGS = @CFLAGS@
PROG = unicon
OBJS = ImmHzInput.o AImmHzInput.o Main.o UniKey.o \
        MyInputArea.o SysConfig.o MyConfig.o ConfigManager.o
S_IMM_LIB = ../client/libimmclient.a
D_IMM_LIB = ../client/libimmclient.a -lpth -ldl -L../server -Wl,-rpath=$(prefix)/lib/unicon -limm_server

#  CFLAGS = -g -Wall -I. -DSIMULATE_OS_KEY -DSIMULATE_OS_VIDEO
# __CLIB24_SUPPORT__
CFLAGS = -g -Wall -I. -I../include -I../../include -I../unikey
CC = g++ -g 
all: $(PROG) unicon.ini

unicon: $(OBJS) $(S_IMM_LIB) 
	$(CC) -ldl $(OBJS) $(D_IMM_LIB) -o $(PROG)

slib: $(OBJS) $(S_IMM_LIB)
	$(CC) $(OBJS) $(S_IMM_LIB) -o $(PROG)
ImmHzInput.o: ImmHzInput.cpp ImmHzInput.hpp
	$(CC) $(CFLAGS) -c ImmHzInput.cpp -o ImmHzInput.o
AImmHzInput.o: AImmHzInput.cpp AImmHzInput.hpp
	$(CC) $(CFLAGS) -c AImmHzInput.cpp -o AImmHzInput.o
MyInputArea.o: MyInputArea.cpp MyInputArea.hpp
	$(CC) $(CFLAGS) -c MyInputArea.cpp -o MyInputArea.o
SysConfig.o : SysConfig.cpp SysConfig.hpp
	$(CC) $(CFLAGS) -c SysConfig.cpp -o SysConfig.o
MyConfig.o : MyConfig.cpp MyConfig.hpp SysConfig.hpp
	$(CC) $(CFLAGS) -DUNICON_LIB=\"$(prefix)/lib/unicon\" -c MyConfig.cpp -o MyConfig.o
UniKey.o : UniKey.hpp UniKey.cpp
	$(CC) $(CFLAGS) -c UniKey.cpp -o UniKey.o
Main.o: Main.cpp
	$(CC) $(CFLAGS) -D__DLL_SUPPORT__ -DUNICON_LIB=\"$(prefix)/lib/unicon\" -c Main.cpp -o Main.o
ConfigManager.o: ConfigManager.cpp
	$(CC) $(CFLAGS) -DUNICON_LIB=\"$(prefix)/lib/unicon\" -c ConfigManager.cpp -o ConfigManager.o

unicon.ini: unicon.ini.in
	sed -e "s.@PREFIX@.$(prefix).g" unicon.ini.in > unicon.ini

install: all
	mkdir -p $(prefix)/bin $(prefix)/lib/unicon
	install -o root -g root -m755 unicon $(prefix)/bin
	install -o root -g root -m644 unicon.ini $(prefix)/lib/unicon
	install -o root -g root -m644 sys-gb.tab $(prefix)/lib/unicon
	install -o root -g root -m644 sys-big5.tab $(prefix)/lib/unicon

clean:
	rm -f *.o core *.bak a.out unicon.ini *~ $(PROG) 

distclean: clean
	rm -f Makefile tags TAGS
